package model

import (
	"gorm.io/gorm"
	"shop/common/global"
	"time"
)

type User struct {
	Id         uint32         `gorm:"column:id;type:int(10) UNSIGNED;primaryKey;not null;" json:"id"`
	CreateTime time.Time      `gorm:"column:create_time;type:datetime(3);not null;default:CURRENT_TIMESTAMP(3);" json:"create_time"`
	UpdateTime time.Time      `gorm:"column:update_time;type:datetime(3);not null;default:CURRENT_TIMESTAMP(3);" json:"update_time"`
	DeleteTime gorm.DeletedAt `gorm:"column:delete_time;type:datetime(3);default:NULL;" json:"delete_time"`
	Account    string         `gorm:"column:account;type:varchar(255);default:NULL;" json:"account"`
	Password   string         `gorm:"column:password;type:varchar(255);default:NULL;" json:"password"`
}

func (User) TableName() string {
	return "user"
}
func (u User) Find(id int) error {
	//根据用户id查用户
	return global.DB.Where("id = ?", id).Find(&u).Error
}
